package com.yuch.controller;


import com.yuch.entity.PhoneCode;
import com.yuch.service.PhoneCodeService;
import com.yuch.utils.CodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/code")
public class SMSController {

    @Autowired
    PhoneCodeService phoneCodeService;

    @GetMapping("/create")
    public String test(){
        String code = phoneCodeService.senSMS("18298063645", 4);
        return code;
    }

    @PostMapping("/vertify")
    public Boolean vertify(@RequestBody PhoneCode phoneCode){
        String code = phoneCode.getCode();
        String s = phoneCodeService.verifyCode(phoneCode.getTel());
        if(s!=null&&s.equals(code)){
            return true;
        }else{
            return false;
        }
    }



}
